import os
from enum import Enum


# 配置的基类
class Config:
    # 配置MySQL参数
    MYSQL_DIALECT = 'mysql'
    MYSQL_DIRVER = 'pymysql'
    MYSQL_NAME = 'chenfanfang'
    MYSQL_PWD = 'wish1992'
    MYSQL_HOST = 'localhost'
    MYSQL_PORT = 3306
    MYSQL_DB = 'flask_shop'
    MYSQL_CHARSET = 'utf8mb4'

    SQLALCHEMY_DATABASE_URI = f'{MYSQL_DIALECT}+{MYSQL_DIRVER}://{MYSQL_NAME}:{MYSQL_PWD}@{MYSQL_HOST}:{MYSQL_PORT}/{MYSQL_DB}?charset={MYSQL_CHARSET}'
    SQLALCHEMY_TRACK_MODIFICATIONS = True
    SECRET_KEY = os.urandom(16)

    ALLOWED_IMGS = set(['bmp', 'png', 'jpg', 'jpeg', 'gif'])
    BASE_DIR = os.path.dirname(os.path.abspath(__file__))
    SERVER_IMG_UPLOADS = os.path.join(BASE_DIR, 'flask_shop', 'static', 'img')


# 开发环境配置类
class DevelopmentConfig(Config):
    DEBUG = True


# 生产环境配置类
class ProductionConfig(Config):
    pass



# 配置类型
class ConfigType(Enum):
    develop = DevelopmentConfig
    product = ProductionConfig
